home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!news
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: void pointers
- Date: 8 Jan 1996 19:23:32 GMT
- Organization: Datalytics, Inc
- Message-ID: <4crqvk$h4r@gold.datalytics.com>
- References: <Pine.SUN.3.91.960105113409.18158A-100000@phoenix.acms.arizona.edu>
- NNTP-Posting-Host: pc071.datalytics.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- Kenton White <jwhite@phoenix.acms.arizona.edu> wrote:
- >
- >
- >I am trying to create a class that stores pointers to other classes in an
- >array of void pointers. Since void pointers cannot be dereferenced, is
- >there any way to cast the void pointer to a non-void pointer and then
- >dereference?
- >
-
- Sure. Cast it and dereference it.
-
- Seriously, this raises the spectre of knowing the actual type
- of what you're pointing to so you cast it to a valid type.
- You cannot cast a pointer to an arbitrary type. Since you're
- talking about classes, the pointer can only be cast to the
- actual type or a base class of the actual type. If you're
- taking the pointer as a void*, how will you know what to cast
- it to later?
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc.
- (513)226-7700
- stew@datalytics.com
-
-
-